package oriol.forns.gutierrez;



import android.app.Activity;
import android.content.Context;
import android.content.Intent;
import android.os.Bundle;
import android.os.Handler;
import android.os.Message;
import android.os.PowerManager;
import android.view.Display;
import android.view.View;
import android.view.WindowManager;
import android.widget.ImageButton;
import android.widget.ImageView;
import android.widget.TextView;

public class Menu extends Activity{
	
	public Handler handler;
	
	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.menus);
		GV.Instancies.menu = (MenuBack) findViewById(R.id.backmenu);
		GV.Instancies.menuact = this;
		
		ImageView ark = (ImageView) findViewById(R.id.ark);
		ark.setImageResource(android.R.color.transparent);
		
		PowerManager pm = (PowerManager) getSystemService(Context.POWER_SERVICE);
		GV.Screen.wl = pm.newWakeLock(PowerManager.FULL_WAKE_LOCK, "GameOnLock");
		
		
		ImageButton play = (ImageButton) findViewById(R.id.play);
		play.setOnClickListener(new View.OnClickListener() {
			public void onClick(View v) {
				Intent i = new Intent("oriol.forns.gutierrez.MAINPAGE");
				startActivity(i);
			}
		});
		
		ImageButton carrega = (ImageButton) findViewById(R.id.carregar);
		carrega.setOnClickListener(new View.OnClickListener() {
			public void onClick(View v) {
				Intent i = new Intent("oriol.forns.gutierrez.CARREGAR");
				startActivity(i);
			}
		});
		
		ImageButton edit = (ImageButton) findViewById(R.id.editor);
		edit.setOnClickListener(new View.OnClickListener() {
			public void onClick(View v) {
				Intent i = new Intent("oriol.forns.gutierrez.EDITOR");
				startActivity(i);
			}
		});
		
		ImageButton instruc = (ImageButton) findViewById(R.id.instruccions);
		instruc.setOnClickListener(new View.OnClickListener() {
			public void onClick(View v) {
				Intent i = new Intent("oriol.forns.gutierrez.INSTRUCCIONS");
				startActivity(i);
			}
		});
		
		ImageButton Ranking = (ImageButton) findViewById(R.id.ranking);
		Ranking.setOnClickListener(new View.OnClickListener() {
			public void onClick(View v) {
				Intent i = new Intent("oriol.forns.gutierrez.RANKING");
				startActivity(i);
			}
		});
		
		ImageButton exit = (ImageButton) findViewById(R.id.cerrar);
		exit.setOnClickListener(new View.OnClickListener() {
			public void onClick(View v) {
				Intent i = new Intent("oriol.forns.gutierrez.CONFIRMACIO");
				startActivity(i);
			}
		});
		
	}

	@Override
	protected void onPause() {
		GV.Instancies.menu.stopthread();
		GV.Screen.wl.release();
		super.onPause();
	}

	@Override
	protected void onResume() {
		if (GV.Instancies.sortir) {
			GV.Instancies.sortir = false;
			finish();
		}
		
		if (GV.Instancies.carrega != -1) {
			Intent i = new Intent("oriol.forns.gutierrez.MAINPAGE");
			startActivity(i);
		}
		GV.Instancies.menu.startthread();
		GV.Screen.wl.acquire();
		super.onResume();
	}
	
	
}
